//package com.zmn.plat.config;
//
//import com.alibaba.nacos.api.config.annotation.NacosConfigListener;
//import com.alibaba.nacos.api.config.annotation.NacosValue;
//import com.zmn.common.utils.string.StringUtil;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.InitializingBean;
//import org.springframework.boot.logging.LogLevel;
//import org.springframework.boot.logging.LoggingSystem;
//import org.springframework.context.annotation.Configuration;
//
//import javax.annotation.Resource;
//import java.util.Properties;
//
///**
// * 类描述：监听nacos动态改变logging 日志级别
// *
// * @author hewenlang
// * @since 2021/12/20 18:16
// */
//@Configuration
//public class LoggingLevelRefresherConfig implements InitializingBean {
//
//    private final static Logger log = LoggerFactory.getLogger(LoggingLevelRefresherConfig.class);
//
//    @NacosValue(value = "${zmn.logging.level}",autoRefreshed = true)
//    private String loggerLevel;
//
//    @Resource
//    private LoggingSystem loggingSystem;
//    /**
//     * 初始化
//     */
//    @Override
//    public void afterPropertiesSet() {
//       if(StringUtil.isNotBlank(loggerLevel)) {
//            LogLevel logLevel = LogLevel.valueOf(loggerLevel.toUpperCase());
//            loggingSystem.setLogLevel("com.alibaba.admin",logLevel);
//            loggingSystem.setLogLevel("org.apache.admin",logLevel);
//            loggingSystem.setLogLevel("java.sql.Connection", logLevel);
//            loggingSystem.setLogLevel("java.sql.Statement", logLevel);
//            loggingSystem.setLogLevel("java.sql.PreparedStatement", logLevel);
//            loggingSystem.setLogLevel("com.zmn", logLevel);
//        }
//    }
//
//
//    /**
//     * nacos监听器
//     * @param properties
//     */
//   @NacosConfigListener(dataId ="${nacos.config.data-id}",groupId = "${nacos.config.group}")
//    public void onChangeValue(Properties properties) {
//        try {
//            String property = properties.getProperty("zmn.logging.level");
//            if (StringUtil.isNotBlank(property)) {
//                log.warn("日志等级变更为:{}", property);
//                LogLevel logLevel = LogLevel.valueOf(property.toUpperCase());
//                loggingSystem.setLogLevel("com.alibaba.admin", logLevel);
//                loggingSystem.setLogLevel("org.apache.admin", logLevel);
//                loggingSystem.setLogLevel("java.sql.Connection", logLevel);
//                loggingSystem.setLogLevel("java.sql.Statement", logLevel);
//                loggingSystem.setLogLevel("java.sql.PreparedStatement", logLevel);
//                loggingSystem.setLogLevel("com.zmn", logLevel);
//            }
//        }catch (Exception e){
//            log.error("[日志等级变更]，参数获取失败");
//        }
//    }
//
//}
